package com.bwie.controller;

import com.bwie.common.domain.User;
import com.bwie.common.result.Result;
import com.bwie.service.SmsRecordService;
import com.bwie.service.SysUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 系统用户控制层
 *
 * @author <a href="mailto:3364114353@qq.com">liuwenliang</a>
 * @version 1.0
 * @description: 系统用户控制层
 * @date 2025/9/9 10:20
 */
@RestController
@RequestMapping("/sysUser")
@CrossOrigin
public class SysUserController {


    @Autowired
    private SysUserService sysUserService;

    @Autowired
    private SmsRecordService smsRecordService;

    /**
     * 查询手机号是否存在
     * @param phone 手机号
     * @return 用户信息
     */
    @GetMapping("/selectPhoneIsExist/{phone}")
    public Result<User> selectPhoneIsExist(@PathVariable("phone") String phone) {
        User loginUser = sysUserService.selectPhoneIsExist(phone);
        return Result.success(loginUser);
    }

    /**
     * 短信息记录
     * @param user
     * @return
     */
    @PostMapping("/addSmsRecord")
    public Result addSmsRecord (@RequestBody User user) {
        smsRecordService.addSmsRecord(user);
        return Result.success();
    }
}
